package com.yami.shop.dao;

import com.yami.shop.bean.model.PostRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 动态记录 Mapper 接口
 * </p>
 *
 * @author chajiu
 * @since 2021-06-28
 */
public interface PostRecordMapper extends BaseMapper<PostRecord> {
    @Insert("INSERT INTO ch_post_record (id, content, pics, user_id, create_time, status, like_num, is_del ) " +
            "VALUES ( #{id}, #{content}, #{pics}, #{userId}, #{createTime}, #{status}, #{likeNum},#{isDel} )")
    int insertOne(PostRecord postRecord);


    @Update("update ch_post_record set like_num = like_num + 1 where id = #{postId}")
    int addOnePostLike(String postId);

    @Update("update ch_post_record set like_num = like_num - 1 where id = #{postId}")
    int subOnePostLike(String postId);
}
